package Backup.Source.Configuration;

// <editor-fold defaultstate="collapsed" desc="import">
import Backup.Library.PathHelper;
import java.io.Console;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
// </editor-fold>

public class PropertiesProvider {    
    
    // <editor-fold defaultstate="collapsed" desc="private varibles">
    private Properties PropertiesInstance;
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="constructors">
    public PropertiesProvider(String propertiesFileName)
    {
        PropertiesInstance = new Properties();
        String ClassPath = getClass().getProtectionDomain().getCodeSource().getLocation().toString().substring(5);
        
        String PropertiesFilePath = PathHelper.combinePaths(ClassPath, "Backup", "Source", "Configuration", propertiesFileName);
        
        try
        {                      
            PropertiesInstance.load(new FileInputStream(PropertiesFilePath));
        }
        catch (IOException Exception)
        {
           System.out.println("Problem occurred while loading configuration file: "+ PropertiesFilePath + "." + Exception); 
        }        
    }    
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="public methods">
    public String getString(String propertyName)
    {        
        return PropertiesInstance.getProperty(propertyName);
    }
    // </editor-fold>
}
